#!/usr/bin/env python
# coding=utf-8

PACKAGE = "pf_driver"

from dynamic_reconfigure.parameter_generator_catkin import *

#----------R2300 Parameters------------------------------------------------------
gen_r2300 = ParameterGenerator()

ip_mode_enum = gen_r2300.enum([ gen_r2300.const("static", str_t, "static", "Static IP mode"),
                          gen_r2300.const("dhcp",   str_t, "dhcp", "DHCP IP mode"),
                          gen_r2300.const("autoip", str_t, "autoip", "AutoIP mode")],
                         "An enum to set IP mode")
gen_r2300.add("ip_mode",              str_t,    1, "ip_mode value determines the method used by the device to determine its own IP and network conﬁguration.", "autoip", edit_method=ip_mode_enum)
gen_r2300.add("ip_address",           str_t,    2, "IP address", "10.0.10.76")
gen_r2300.add("subnet_mask",          str_t,    3, "IP netmask", "255.0.0.0")
gen_r2300.add("gateway",              str_t,    4, "IP gateway", "0.0.0.0")
gen_r2300.add("user_tag",             str_t,    5, "Short UTF8 string for user purposes, up to 32 bytes not chars! (32 chars on R2000)", "OMD10M-R2300")

layer_enum = gen_r2300.enum([ gen_r2300.const("on_on_on_on",     str_t, "on,on,on,on", ""),
                        gen_r2300.const("on_on_on_off",    str_t, "on,on,on,off", ""),
                        gen_r2300.const("on_on_off_on",    str_t, "on,on,off,on", ""),
                        gen_r2300.const("on_on_off_off",   str_t, "on,on,off,off", ""),
                        gen_r2300.const("on_off_on_on",    str_t, "on,off,on,on", ""),
                        gen_r2300.const("on_off_on_off",   str_t, "on,off,on,off", ""),
                        gen_r2300.const("on_off_off_on",   str_t, "on,off,off,on", ""),
                        gen_r2300.const("on_off_off_off",  str_t, "on,off,off,off", ""),
                        gen_r2300.const("off_on_on_on",    str_t, "off,on,on,on", ""),
                        gen_r2300.const("off_on_on_off",   str_t, "off,on,on,off", ""),
                        gen_r2300.const("off_on_off_on",   str_t, "off,on,off,on", ""),
                        gen_r2300.const("off_on_off_off",  str_t, "off,on,off,off", ""),
                        gen_r2300.const("off_off_on_on",   str_t, "off,off,on,on", ""),
                        gen_r2300.const("off_off_on_off",  str_t, "off,off,on,off", ""),
                        gen_r2300.const("off_off_off_on",  str_t, "off,off,off,on", ""),
                        gen_r2300.const("off_off_off_off", str_t, "off,off,off,off", "")],
                        "An enum to set layers")
gen_r2300.add("layer_enable",         str_t,    6, "An on or off value for each of the layers indexed 0..3 determines whether measurement takes place in that layer. When setting, specify the values as comma-separated list.", "on,on,on,on", edit_method=layer_enum)
gen_r2300.add("scan_frequency",       int_t,    7, "The scan_frequency determines the number of scans taken per second. A scan means a contiguous set of measurements taken within range measure_start_angle to measure_stop_angle. Changing the scan_frequency to either 50 or 100 Hz as a side effect also determines the angular resolution: 0.1° at 50 Hz or 0.2° at 100 Hz.", 100)
gen_r2300.add("scan_direction",       str_t,    8, "The scan_direction may allow to change the direction of scanning and therefore also the order of the measurements (direction of ﬁrst measurement) in time. Currently, the setting is ﬁxed to 'ccw' (counter-clockwise, mathematically positive), and 'cw' (clockwise) is not really supported.", "ccw")
gen_r2300.add("measure_start_angle",  double_t, 9, "measure_start_angle (unit: 1/10000 degree) limits the scanning range at one end, while measure_stop_angle determines the other end limit. Scans consist of all samples exactly at and between those two limits, taken at angles rounded to multiples of the current angular resolution as determined by scan_frequency. This is a persistent setting, kept in persistent memory. For dynamic selection of measurement range without wearing out parameter memory, it is recommended to utilize the Scan output options start_angle and max_num_points_scan instead.", -500000,  -500000, 500000)
gen_r2300.add("measure_stop_angle",   double_t, 10, "See measure_start_angle for description", 500000,  -500000, 500000)

locator_indicator_enum = gen_r2300.enum([ gen_r2300.const("locator_on",  str_t, "on", ""),
                                    gen_r2300.const("locator_off", str_t, "off", "")],
                                    "An enum to set locator indicator")
gen_r2300.add("locator_indication",   str_t,    11, "Enable locator indication (on/off)", "off", edit_method=locator_indicator_enum)

pilot_laser_enum = gen_r2300.enum([ gen_r2300.const("pilot_on",  str_t, "on", ""),
                              gen_r2300.const("pilot_off", str_t, "off", "")],
                              "An enum to set pilot laser")
gen_r2300.add("pilot_laser",          str_t,    12, "General on or off switch for the red pilot laser. Its actual visibility (in current scanners) is further limited to the range in which measurement takes place, i.e. from measure_start_angle to measure_stop_angle, and also depends on the value of layer_enable.", "off", edit_method=pilot_laser_enum)
gen_r2300.add("pilot_start_angle",    double_t, 13, "Angle where to enable red pilot laser", -500000,  -500000, 500000)
gen_r2300.add("pilot_stop_angle",     double_t, 14, "Angle where to disable red pilot laser", 500000,  -500000, 500000)

operating_mode_enum = gen_r2300.enum([ gen_r2300.const("measure",     str_t, "measure", "measure mode"),
                                 gen_r2300.const("emitter_off", str_t, "emitter_off", "emitter_off mode")],
                                 "An enum to set operating mode")
gen_r2300.add("operating_mode",       str_t,    15, "The operating_mode, always measure after power on, can be temporarily set to emitter_off to disable the laser pulse, e.g. in order to avoid affecting other scanners.", "measure", edit_method=operating_mode_enum)
gen_r2300.add("address",              str_t,    16, "When initiating scan data output, request_handle_udp must be given an IPv4 address and port in order to know where to send scandata to. The IPv4 typically should be the IP address of the host who also initiates the connection, e.g. 10.0.10.10, the port something like 6464.")
gen_r2300.add("port",                 int_t,    17, "See address")
gen_r2300.add("packet_type",          str_t,    18, "Packet type for scan data output (always C1 on R2300)", "C1")
gen_r2300.add("packet_crc",           str_t,    19, "Append extra CRC32 for scan data integrity check (currenty always none on R2300)")
gen_r2300.add("watchdog",             str_t,    20, "Cease scan data output if watchdog isn't fed in time (always off on R2300)", "off")
gen_r2300.add("watchdogtimeout",      int_t,    21, "Maximum time for client to feed watchdog", 0)
gen_r2300.add("start_angle",          double_t, 22, "Specifying a start_angle (in 1/10000 degree) allows to reduce the output of data. ∗ While device global settings measure_start_angle and measure_stop_angle determine the range where actual measurements (and laser pulses) take place, start_angle may be used to tell the scanner to include only a subset of the data (starting at or after start_angle) in the scan output. This is provided for compatibility with R2000, where more than one consumer might want different portions of the data, and so you don't have to dynamically update measure_start_angle continuously just to get another range output. The default is -1800000, which means all data.", -1800000, -1800000)
gen_r2300.add("max_num_points_scan",  int_t,    23, "Specifying a max_num_points_scan (in 1/10000 degree) allows to reduce the output of data to the given number of measurements (or less if there are less in actual scan range). The default is 0, meaning all data. Note that the same number of measurements may cover double (or half) the angular range dependent on device global setting scan_frequency and thus angular resolution.", 0, 0)
gen_r2300.add("skip_scans",           int_t,    24, "Omit this number of scans (x layers) between output (always 0)", 0, 0)

gen_r2300.generate(PACKAGE, "r2300_node", "PFDriverR2300")

